<?php
/**
 * ===============================================
 * 版权所有 2019-2050 青岛铁锤科技有限公司，并保留所有权利。
 * 网站地址: http://www.huaxianling.com
 * ===============================================
 * Author: Happy dong
 * Created Time: 2019-07-11 17:38
 *
 * Version: 2.0
 */

namespace App\Modules\Employee\Repositories;


use App\Models\UserPortfolioResource;
use App\Modules\Employee\Validators\PortfolioResourceValidator;
use Flower\Core\Repository\Eloquent\BaseRepository;

class PortfolioResourceRepository extends BaseRepository
{
	public function model()
	{
		return UserPortfolioResource::class;
	}

	public function validator()
	{
		return PortfolioResourceValidator::class;
	}

	/**
	 * 批量新增数据
	 * @param $data
	 * @return mixed
	 */
	public function add($data)
	{
		return $this->model->insert($data);
	}

	/**
	 * 新增资源数据
	 * @param $portfolioId
	 * @param $resourceId
	 * @return mixed
	 */
	public function addResource($portfolioId, $resourceId)
	{
		$params = [
			'portfolio_id' => $portfolioId,
			'type'         => config("constant.resourceType.video"),
		];
		return $this->updateOrCreate($params, ['resource_id'  => $resourceId]);
	}
}